﻿using QLKS2014.BLL;
using QLKS2014.PUBLIC;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace QLKS2014.GUI.StupidWindow
{
    /// <summary>
    /// hien thi danh sach cac khach hang da thue phong
    /// </summary>
    public partial class DetailRoomRentedWindow : Window, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string _PropertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(_PropertyName));
        }
        ObservableCollection<KhachHangPublic> _ocKhachHang; //=> Danh sach nhung phong con trong

        public ObservableCollection<KhachHangPublic> OcKhachHang
        {
            get { return _ocKhachHang; }
            set { _ocKhachHang = value;
            OnPropertyChanged("OcKhachHang");
            }
        }

        
        //tao ket noi du lieu
        //static SqlCeConnection connectionData;

        public DetailRoomRentedWindow()
        {
            InitializeComponent();
            
            Loaded += DetailRoomRented_Loaded;
        }

        /// <summary>
        /// hien thi thong tin
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void DetailRoomRented_Loaded(object sender, RoutedEventArgs e)
        {
            _initialize();
        }

        private void _initialize()
        {
            List<KhachHangPublic> lKhachHang = new KhachHangBll().selectAll();
            if (lKhachHang != null)
                OcKhachHang = new ObservableCollection<KhachHangPublic>(lKhachHang);
            else
                OcKhachHang = new ObservableCollection<KhachHangPublic>();
        }

        /// <summary>
        /// lay ngay ket thuc thue phong
        /// </summary>
        /// <param name="idRentRoom">ma phieu thue phong</param>
        /// <returns></returns>
        private string getEndDate(string idRentRoom_, DateTime startDate_)
        {
            //TimeSpan totalDay = new TimeSpan();
            //string cmdText = "";
            //cmdText = "SELECT SoNgayThue FROM CHITIETHD WHERE MaPTP = " + idRentRoom_;
            //using (SqlCeCommand cmdGetEndDate = new SqlCeCommand(cmdText, connectionData))
            //{
            //    SqlCeDataReader reader2 = cmdGetEndDate.ExecuteReader();
            //    while (reader2.Read())
            //    {
            //        totalDay = TimeSpan.Parse(reader2["SoNgayThue"].ToString());
            //    }
            //}
            ////tinh ngay ket thuc
            //DateTime endDate = startDate_.Add(totalDay);
            //if (startDate_.Equals(endDate))
            //    return "";
            //return endDate.ToString();
            return null;
        }

        private void dgCustomer_KeyDown(object sender, KeyEventArgs e)
        {

        }

        private void dgCustomer_LoadingRow(object sender, DataGridRowEventArgs e)
        {

        }       
    }
}